﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExaminationSys.Helper;
using ExaminationSys.DataAccess.Entity;
using ExaminationSys.DataAccess.Repository;
using ExaminationSys.DataAccess;

namespace ExaminationSys.View.Share
{
    public partial class LeftUserInfoControl : System.Web.UI.UserControl
    {
        public string UserName { get; set; }
        private static readonly SectionInfoService Proxy = ObjectFactory<SectionInfoService>.Create();
        protected void Page_Load(object sender, EventArgs e)
        {
            var item = FormsAuthenticationHelper.GetCurrentTeacherInfo();
            if (item != null)
            {
                UserName = item.UserName;
                QuestionCount.Text = "0";
                var countTablelist = Proxy.GetTableCount();
                foreach (var countTb in countTablelist)
                {
                    if (countTb.Title == "栏目数")
                    {
                        SectionCount.Text = countTb.Counts.ToString();
                        continue;
                    }
                    if (countTb.Title == "普通题数" || countTb.Title == "大题数")
                    {
                        QuestionCount.Text = (int.Parse(QuestionCount.Text) + countTb.Counts).ToString(); ;
                        continue;
                    }
                    if (countTb.Title == "试卷数")
                    {
                        PaperCount.Text = countTb.Counts.ToString(); ;
                        continue;
                    }
                    if (countTb.Title == "教师数")
                    {
                        TeacherCount.Text = countTb.Counts.ToString(); ;
                        continue;
                    }
                    if (countTb.Title == "学生数")
                    {
                        StudentCount.Text = countTb.Counts.ToString(); ;
                        continue;
                    }

                }


            }
            else
            {
                Response.Redirect("~/Account/Login.aspx");
            }
        }

    }
}